var Mymixin = {
  data() {
    return {
      pageTwomyChart: ""
    }
  },
  updated: function () {
    console.log("之前的数据是" + this.num + ".");
  },
  methods: {
    InitChart() {
      let myChart = this.$echarts.init(document.getElementById('page2tu'))
      // 指定图表的配置项和数据
      var option = {
        color: ['#7bbfea', '#00796a', '#e1251b'],
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            crossStyle: {
              color: '#999',
            },
          },
          formatter: function (params) {
            var relVal = params[0].name
            for (var i = 0, l = params.length; i < l; i++) {
              if (params[i].seriesName === '实时建议利率') {
                relVal += '<br/>' + params[i].seriesName + '(%)' + ' : ' + params[i].value
                relVal += '<br/>' + '平均建议利率(%)' + ' : ' + params[i].value
              }
            }
            return relVal
          },
        },
        toolbox: {
          // feature: {
          //     dataView: { show: true, readOnly: false },
          //     magicType: { show: true, type: ['line', 'bar'] },
          //     restore: { show: true },
          //     saveAsImage: { show: true },
          // },
        },
        legend: {
          data: ['实时建议利率'],
        },
        xAxis: [
          {
            type: 'category',
            boundaryGap: false,
            data: [
              '2021/3/16',
              '2021/3/16',
              '2021/4/10',
              '2021/5/16',
              '2021/5/30',
              '2021/6/20',
              '2021/7/16',
            ],
            axisPointer: {
              type: 'shadow',
            },
          },
        ],
        yAxis: [
          {
            type: 'value',
            name: '',
            min: 0,
            max: 15,
            interval: 5,
            axisLabel: {
              formatter: '{value} %',
            },
          },
        ],
        grid: {
          right: 5,
          left: 5,
          top: 50,
          containLabel: true,
        },
        series: [
          {
            name: '实时建议利率',
            type: 'line',
            symbol: 'none',
            smooth: true,
            data: [8.6, 5.6, 2.3, 5.6, 3, 8.0, 5.3, 6.5, 6.2, 8.4],
            areaStyle: {
              color: {
                type: 'linear',
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 0,
                    color: 'rgba(58,132,255, 0.5)', // 0% 处的颜色
                  },
                  {
                    offset: 1,
                    color: 'rgba(58,132,255, 0)', // 100% 处的颜色
                  },
                ],
                global: false, // 缺省为 false
              },
            },
          },
        ],
      }
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option)
      myChart.on('click', function (e) {
        console.log('444', e)
      })
    },
  }
}